package tree;

import offer.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class leetCode129_sumNumbers {
    public int sumNumbers(TreeNode root) {
        if(root == null) return 0;
        return build(root,0);
    }

    public int build(TreeNode root,int tmp){
        if(root == null){
            return 0;
        }
        tmp = tmp * 10 + root.val;
        if(root.left == null && root.right == null){
            return tmp;
        }

        return build(root.left,tmp) + build(root.right,tmp);
    }





}
